<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class AdminInfo extends Model
{
    protected $primaryKey = 'user_id';

    public $timestamps = false;

    public $fillable = [
    	'user_id',
		'name',
		'phone',
		'sex',
    ];

    protected $appends = [
    	'sex_description',
    ];

    const SEX_MALE = 1;
    const SEX_FEMALE = 2;

    public static $_SEX_DESCRIPTION = [
    	self::SEX_FEMALE => '女',
    	self::SEX_MALE => '男',
    ];

    public function getSexDescriptionAttribute($value)
    {
    	if(array_key_exists('sex', $this->attributes))
    	{
            if(is_null($this->attributes['sex']) || $this->attributes['sex'] == 0)
            {
                return ;
            }
    		return self::$_SEX_DESCRIPTION[$this->attributes['sex']];
    	}
    }
}
